//
//  ADHomeViewTitleButton.swift
//  myBlog
//
//  Created by mac2014 on 16/3/26.
//  Copyright © 2016年 AD. All rights reserved.
//

import UIKit
/// 导航栏标题按钮的设置:点击翻转并弹出一个view
class ADHomeViewTitleButton: UIButton {
    //便利构造函数
    convenience init(title: String, imageName: String) {
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        sizeToFit()
    }
    
    //重新设定箭头和文本框的位置
    override func layoutSubviews() {
        super.layoutSubviews()
        //文本框的位置
        titleLabel?.frame.origin.x = 0
        
        //箭头的位置
        imageView?.frame.origin.x = titleLabel!.frame.width + 5.0
    }
}
